import type { GreasyForkElements } from '../../../../../../../../../types/constants/personalization/greasy_fork'
import {
  PAGE_ELEMENTS,
  PROJECT_PREFIX,
  SUPPORTED_PLATFORMS,
} from '../../../../../../../../../types/constants'
import { getElementSelector } from '../../../../../../../../../types/constants/personalization/common'

export class CodePage {
  elements: GreasyForkElements = PAGE_ELEMENTS[SUPPORTED_PLATFORMS.GREASY_FORK]
  private readonly containerSelector = getElementSelector(this.elements, 'COMMON_CONTAINER')
  private static instance: CodePage

  /**
   * 获取单例实例
   */
  public static getInstance(): CodePage {
    if (!CodePage.instance) {
      CodePage.instance = new CodePage()
    }
    return CodePage.instance
  }

  init(): void {
  }

  getMainStyles(): string {
    if (this.containerSelector.length === 0)
      return ''

    return `
${this.containerSelector} {
  .code-container {
    border: none !important;

    pre {
    
      &:hover {
        transform: none !important;
      }
      
      ol li {
        background-color: var(--${PROJECT_PREFIX}-theme-code-bg) !important;
      }
    }
  }
}
`
  }
}
